﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using RouterControl.IO;

namespace RouterControl.WhsAddIn.SettingsControls
{
	public partial class AboutRouterControl : SettingsControlBase
	{
		public AboutRouterControl(RouterControlSettingsTab2 tab)
			: base(tab)
		{
			if (_log.IsDebugEnabled)
				_log.Debug("Initialization start");

			try
			{
				InitializeComponent();
	
				this.lineBox.Header.Text = Properties.Resources.txtAbout;

				// set version text
				this.aboutVersionTextLabel.Text = string.Format(
					Properties.Resources.txtAboutVersionText,
					RouterControlVersion.VersionString
					);

			    this.instanceIdTB.Text = Whs.RouterControlRegistry.GetInstanceId().ToString("D");

				// done
				if (_log.IsDebugEnabled)
					_log.Debug("Initialization done");
			}
			catch (Exception e)
			{
				_log.Fatal("Failed to initialize", e);

				throw;
			}
		}

		private void homepageLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			_tab.Services.OpenUrl(Whs.Properties.Constants.HomepageUrl);
		}

		private void donateLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			_tab.Services.OpenUrl(Whs.Properties.Constants.DonateUrl);
		}

		private void showLicenseLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			_tab.Services.OpenUrl(Whs.Properties.Constants.LicenseUrl);
		}

	}
}
